package jircbot.irc;

/**
 * Provides methods for controlling the irc bot for any plugins.
 *
 * Information on the different commands can be found from
 * <a href="http://en.wikipedia.org/wiki/List_of_Internet_Relay_Chat_commands">
 * this wikipedia page</a>.
 * 
 * @author matt
 */
public class IrcController {
	private Irc irc;

	/**
	 * Constructor method
	 *
	 * @param irc The irc object to be controlled
	 */
	public IrcController(Irc irc)
	{
		this.irc = irc;
	}

	/**
	 * Send a message to a user or chat room
	 *
	 * @param target The nick on channel to send the message to
	 * @param message The message to send
	 */
	public void privmsg(String target, String message)
	{
		irc.sendLine("PRIVMSG " + target + " " + message);
	}
	
	/**
	 * Sets the nick
	 *
	 * @param nick The specified nick
	 */
	public void nick(String nick)
	{
		irc.setNick(nick);
	}

	public void join(String channel)
	{
		irc.joinChannel(channel);
	}

	public void join(String channel, String key)
	{
		irc.sendLine("JOIN " + channel + " " + key);
	}

	public void quit(String message)
	{
		irc.sendLine("QUIT " + message);
	}

	public void away(String message)
	{
		irc.sendLine("AWAY " + message);
	}

	public void list(String channels, String servers)
	{
		irc.sendLine("LIST " + channels + " " + servers);
	}

	public void kick(String channel, String client)
	{
		irc.sendLine("KICK " + channel + " " + client);
	}

	public void kick(String channel, String client, String message)
	{
		irc.sendLine("KICK " + channel + " " + client + " " + message);
	}

	public void invite(String nick, String channel)
	{
		irc.sendLine("INVITE " + nick + " " + channel);
	}

	public void part(String channels)
	{
		irc.sendLine("PART " + channels);
	}

	public void mode(String nick, String flags)
	{
		irc.sendLine("MODE " + nick + " " + flags);
	}

	public void mode(String channel, String flags, String args)
	{
		irc.sendLine("MODE " + channel + " " + flags + " " + args);
	}

	public void motd(String server)
	{
		irc.sendLine("MOTD " + server);
	}

	public void notice(String target, String message)
	{
		irc.sendLine("NOTIC " + target + " " + message);
	}

	public void admin(String server)
	{
		irc.sendLine("ADMIN " + server);
	}

	public void users(String server)
	{
		irc.sendLine("SERVER " + server);
	}

	public void whoIs(String nick)
	{
		irc.sendLine("WHOIS " + nick);
	}

	public void whoIs(String nick, String server)
	{
		irc.sendLine("WHOIS " + server + " " + nick);
	}

	public void whoWas(String nick, String count, String server)
	{
		irc.sendLine("WHOWAS " + nick + " " + count + " " + server);
	}

	/**
	 * For more advance users to send commands not already provided for.
	 *
	 * @param command
	 */
	public void command(String command)
	{
		irc.sendLine(command);
	}
}
